package com.journey.service.impl;

import com.journey.domain.Ad;
import com.journey.dto.AdDto;
import com.journey.mapper.AdMapper;
import com.journey.service.AdService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by ADMIN on 2018/6/14.
 */
@Service
public class AdServiceImpl implements AdService{
    @Autowired
    private AdMapper adMapper;

    @Override
    public List<AdDto> searchByPage(AdDto adDto) {
        List<AdDto> result = new ArrayList<AdDto>();
        Ad condition = new Ad();
        BeanUtils.copyProperties(adDto , condition);
        List<Ad> adList = adMapper.selectByPage(condition);
        for (Ad ad : adList) {
            AdDto adDtoTemp = new AdDto();
            result.add(adDtoTemp);
            BeanUtils.copyProperties(ad , adDtoTemp);
        }
        return result;
    }
}
